package com.yuexiang.melodyhub.gateway.filter;

import com.yuexiang.melodyhub.gateway.filter.security.AuthProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class AuthFilter implements GlobalFilter {

    private final AuthProcessor authChain;

    @Autowired
    public AuthFilter(@Qualifier("authProcessorChain") AuthProcessor authChain) {
        this.authChain = authChain;
    }

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        return authChain.process(exchange, chain);

    }

}
